using System.Globalization;
using System.Threading;
using System.Web.Mvc;
using Microsoft.Practices.ServiceLocation;
using OTE.Web.Infrastructure.Session;
using SharpArch.Domain.Commands;

namespace OTE.Web.Infrastructure
{
    public class OTEController : Controller
    {
        protected IPersistentWebState WebSession { get; private set; }

        protected ICommandProcessor CommandProcessor { get; private set; }

        public OTEController()
            : this(ServiceLocator.Current.GetInstance<IPersistentWebState>(),
                   ServiceLocator.Current.GetInstance<ICommandProcessor>())
        {
        }

        public OTEController(IPersistentWebState webSession, ICommandProcessor commandProcessor)
        {
            WebSession = webSession;
            CommandProcessor = commandProcessor;
        }

        protected CultureInfo Culture
        {
            get { return Thread.CurrentThread.CurrentUICulture; }
            set
            {
                Thread.CurrentThread.CurrentCulture = value;
                Thread.CurrentThread.CurrentUICulture = value;
            }
        }
    }
}